package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Favorites;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IDailyService;
import cn.wolfcode.trip.base.service.IFavoritesService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/favorites")
public class FavoritesController {
    @Autowired
    private IFavoritesService favoritesService;
    @Autowired
    private IDailyService dailyService;
    @PostMapping("/{userId}/{dailyId}")
    public JSONResult insertFavorites(Favorites favorites){
        favoritesService.insertFavorites(favorites);
        return new JSONResult();
    }
    @DeleteMapping("/{userId}/{dailyId}")
    public JSONResult deleteFavorites(Favorites favorites){
        favoritesService.deleteFavorites(favorites);
        return new JSONResult();
    }
    @GetMapping("/{userId}/{dailyId}")
    public Favorites getFavoritesById(Favorites favorites){
        return dailyService.getFavoritesById(favorites);
    }

    @GetMapping("/{userId}/strategy")
    public PageInfo getStrategyFavoritesByUserId(QueryObject qo){
        return favoritesService.getStrategyFavoritesByUserId(qo);

    }

    @GetMapping("/{userId}/travels")
    public PageInfo getTravelFavoritesByUserId(QueryObject qo){
        return favoritesService.getTravelFavoritesByUserId(qo);
    }



    @GetMapping("/{userId}/daily")
    public PageInfo getDailyFavoritesByUserId(QueryObject qo){
        return favoritesService.getDailyFavoritesByUserId(qo);
    }

    @GetMapping("/{userId}/strategyCounts")
    public Long getStrategyFavoritesCounts(@PathVariable Long userId){
        return favoritesService.getStrategyFavoritesCounts(userId);
    }

    @GetMapping("/{userId}/dailyCounts")
    public Long getDailyFavoritesCounts(@PathVariable Long userId){
        return favoritesService.getDailyFavoritesCounts(userId);
    }

    @GetMapping("/{userId}/travelCounts")
    public Long getTravelFavoritesCounts(@PathVariable Long userId){
        return favoritesService.getTravelFavoritesCounts(userId);
    }
}